/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.informet.ipd.struts.action;

import com.informet.ipd.modelo.dao.MarcoLogicoDao;
import com.informet.ipd.modelo.dao.ProgEstrDao;
import com.informet.ipd.modelo.dao.ProgEstrMarLogDao;
import com.informet.ipd.modelo.dao.ProgEstrMarLogDaoC;
import com.informet.ipd.modelo.dao.ProgEstrMarLogDaoComponenteMeta;
import com.informet.ipd.modelo.dao.ProgEstrMarLogDaoFinMeta;
import com.informet.ipd.modelo.dao.ProgEstrMarLogDaoP;
import com.informet.ipd.modelo.dao.ProgEstrMarLogDaoPropositoMeta;
import com.informet.ipd.modelo.dao.ProyectoInversionDao;
import com.informet.ipd.modelo.vo.ProyectosInversionVO;
import com.informet.ipd.modelo.vo.UbigeoVO;
import com.informet.ipd.struts.form.ProgEstrForm;
import com.informet.ipd.struts.form.ProyectosInversionForm;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.swing.JOptionPane;
import org.apache.commons.lang.StringUtils;


import org.apache.struts.actions.DispatchAction;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;

/**
 *
 * @author Fiorella
 */
public class ProgramasEstrategicosAction extends DispatchAction {

    public ActionForward load(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        ProgEstrForm form1 = (ProgEstrForm) form;
        //UsuarioRolForm form1 = (UsuarioRolForm) form;
        List listOGE = new ProgEstrDao().getlistOGE();
        List listOEE = new ProgEstrDao().getlistOEE(0);
        List listActividades = new ProgEstrDao().getlistActividades(0);
        List listAnios = new ProgEstrDao().getlistAnios();
        List listTableTituProg = new ProgEstrDao().getListTituProgForTable();

//         form1.setListaRol(null);
        form1.setOGE(listOGE);
//        JOptionPane.showMessageDialog(null, form1.getOGE().size());
        form1.setOEE(listOEE);
        form1.setACTIVIDAD(listActividades);
        form1.setListAnio(listAnios);
        form1.setListTableTituProg(listTableTituProg);


        return mapping.findForward("progEstra");
    }

    public ActionForward listarMarcoLogico(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        ProgEstrForm form1 = (ProgEstrForm) form;
        List listaDetailMarLogFin = new MarcoLogicoDao().getlistMarcoLogicoProgramaI();
        List listaDetailMarLogProg = new MarcoLogicoDao().getlistMarcoLogicoPrograma();
        form1.setListPrograma(listaDetailMarLogFin);
        form1.setListProyecto(listaDetailMarLogProg);
        return mapping.findForward("marcoLogicoAnual");
    }

    public ActionForward loadMeta(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        ProgEstrForm form1 = (ProgEstrForm) form;
        int codPrograma = Integer.parseInt(request.getParameter("codPrograma"));
        String descPrograma = request.getParameter("desc");
        form1.setTitu_programa(descPrograma);
        form1.setCodPrograma(codPrograma);
        List listaDetailMarLogFin = new ProgEstrMarLogDao().getlistMarLogFin(codPrograma);
        //List listaDetailMarLogFinComponente=new ProgEstrMarLogDao().getlistMarLogComponente(codPrograma);
        //List listaDetailMarLogProposito=new ProgEstrMarLogDao().getlistMarLogProposito(codPrograma);


        form1.setListDetalleMarcoLogicoFin(listaDetailMarLogFin);
        //   form1.setListDetalleMarcoLogicoComponente(listaDetailMarLogFinComponente);
        // form1.setListDetalleMarcoLogicoProposito(listaDetailMarLogProposito);


        return mapping.findForward("progEstraMarcoLogico");
    }

    public ActionForward loadFinInv(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        ProgEstrForm form1 = (ProgEstrForm) form;
        int codPrograma = Integer.parseInt(request.getParameter("codPrograma"));
        
        String descPrograma = request.getParameter("desc");
       
        form1.setTitu_programa(descPrograma);
        form1.setCodPrograma(codPrograma);
        List listaDetailMarLogFin = new ProgEstrMarLogDao().getlistFinInv(codPrograma);
                
        int flag=(new ProgEstrMarLogDao()).getMuestrafin(codPrograma);


        //List listaDetailMarLogFinComponente=new ProgEstrMarLogDao().getlistMarLogComponente(codPrograma);
        //List listaDetailMarLogProposito=new ProgEstrMarLogDao().getlistMarLogProposito(codPrograma);

//JOptionPane.showMessageDialog(null, listaDetailMarLogFin.size());
        form1.setListDetalleMarcoLogicoFin(listaDetailMarLogFin);
        form1.setFlag(flag);
        //   form1.setListDetalleMarcoLogicoComponente(listaDetailMarLogFinComponente);
        // form1.setListDetalleMarcoLogicoProposito(listaDetailMarLogProposito);


        return mapping.findForward("progEstraInvFin");
    }

    public ActionForward loadProposito(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        ProgEstrForm form1 = (ProgEstrForm) form;
        int codPrograma = Integer.parseInt(request.getParameter("codPrograma"));
        String descPrograma = request.getParameter("desc");
        form1.setTitu_programa(descPrograma);
        form1.setCodPrograma(codPrograma);
        List listaDetailMarLogProposito = new ProgEstrMarLogDaoP().getlistMarLogProposito(codPrograma);
        //List listaDetailMarLogFinComponente=new ProgEstrMarLogDao().getlistMarLogComponente(codPrograma);
        //List listaDetailMarLogProposito=new ProgEstrMarLogDao().getlistMarLogProposito(codPrograma);


        form1.setListDetalleMarcoLogicoProposito(listaDetailMarLogProposito);
        //   form1.setListDetalleMarcoLogicoComponente(listaDetailMarLogFinComponente);
        // form1.setListDetalleMarcoLogicoProposito(listaDetailMarLogProposito);


        return mapping.findForward("progEstraMarLogProposito");
    }

    public ActionForward loadPropositoInv(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        ProgEstrForm form1 = (ProgEstrForm) form;
        int codPrograma = Integer.parseInt(request.getParameter("codPrograma"));
        String descPrograma = request.getParameter("desc");
        form1.setTitu_programa(descPrograma);
        form1.setCodPrograma(codPrograma);
        List listaDetailMarLogProposito = new ProgEstrMarLogDaoP().getlistPropositoInv(codPrograma);
        //List listaDetailMarLogFinComponente=new ProgEstrMarLogDao().getlistMarLogComponente(codPrograma);
        //List listaDetailMarLogProposito=new ProgEstrMarLogDao().getlistMarLogProposito(codPrograma);


        form1.setListDetalleMarcoLogicoProposito(listaDetailMarLogProposito);
        //   form1.setListDetalleMarcoLogicoComponente(listaDetailMarLogFinComponente);
        // form1.setListDetalleMarcoLogicoProposito(listaDetailMarLogProposito);


        return mapping.findForward("progEstraInvProposito");
    }

    public ActionForward loadComponentes(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        ProgEstrForm form1 = (ProgEstrForm) form;
        int codPrograma = Integer.parseInt(request.getParameter("codPrograma"));
        String descPrograma = request.getParameter("desc");
        form1.setTitu_programa(descPrograma);
        form1.setCodPrograma(codPrograma);
        List listaDetailMarLogComponentes = new ProgEstrMarLogDaoC().getlistMarLogComponente(codPrograma);
        //List listaDetailMarLogFinComponente=new ProgEstrMarLogDao().getlistMarLogComponente(codPrograma);
        //List listaDetailMarLogProposito=new ProgEstrMarLogDao().getlistMarLogProposito(codPrograma);


        form1.setListDetalleMarcoLogicoComponente(listaDetailMarLogComponentes);
        //   form1.setListDetalleMarcoLogicoComponente(listaDetailMarLogFinComponente);
        // form1.setListDetalleMarcoLogicoProposito(listaDetailMarLogProposito);


        return mapping.findForward("progEstraMarLogComponentes");
    }

    public ActionForward loadComponentesInv(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        ProgEstrForm form1 = (ProgEstrForm) form;
        int codPrograma = Integer.parseInt(request.getParameter("codPrograma"));
        String descPrograma = request.getParameter("desc");
        form1.setTitu_programa(descPrograma);
        form1.setCodPrograma(codPrograma);
        List listaDetailMarLogComponentes = new ProgEstrMarLogDaoC().getlistMarLogComponenteInv(codPrograma);
        //List listaDetailMarLogFinComponente=new ProgEstrMarLogDao().getlistMarLogComponente(codPrograma);
        //List listaDetailMarLogProposito=new ProgEstrMarLogDao().getlistMarLogProposito(codPrograma);
        List listaDetailComponente = new ProgEstrMarLogDaoC().loadComponentes(codPrograma);
        form1.setComponente(listaDetailComponente);

        form1.setListDetalleMarcoLogicoComponente(listaDetailMarLogComponentes);
        //   form1.setListDetalleMarcoLogicoComponente(listaDetailMarLogFinComponente);
        // form1.setListDetalleMarcoLogicoProposito(listaDetailMarLogProposito);


        return mapping.findForward("progInvComponentes");
    }

    public ActionForward loadFinMeta(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {


        ProgEstrForm form1 = (ProgEstrForm) form;
        int cod = Integer.parseInt(request.getParameter("cod"));// codigo de fin, proposito, componente
        String desc = request.getParameter("desc");// descripcion de fin, proposito, componente
        String descPrograma = request.getParameter("descPrograma");// descripcion de programa
        int codPrograma = Integer.parseInt(request.getParameter("codPrograma"));
        form1.setPk(codPrograma);
        form1.setTitu_programa(descPrograma);
        form1.setMetaFin(desc);
        form1.setCodPrograma(cod);
        

        List listaDetailMarLogFM = new ProgEstrMarLogDaoFinMeta().getlistMarLogFinMeta(cod);

        form1.setListDetalleMarcoLogicoFin(listaDetailMarLogFM);

        return mapping.findForward("progEstraMarLogFinMeta");
    }

    public ActionForward loadMetaFinInv(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {


        ProgEstrForm form1 = (ProgEstrForm) form;
        int cod = Integer.parseInt(request.getParameter("cod"));// codigo de fin, proposito, componente
        String desc = request.getParameter("desc");// descripcion de fin, proposito, componente
        String descPrograma = request.getParameter("descPrograma");// descripcion de programa
        int codPrograma= Integer.parseInt(request.getParameter("codPrograma"));
         form1.setPk(codPrograma);
        form1.setTitu_programa(descPrograma);
        form1.setMetaFin(desc);
        form1.setCodPrograma(cod);

        List listaDetailMarLogFM = new ProgEstrMarLogDaoFinMeta().getlistMetaFinPI(cod);

        form1.setListDetalleMarcoLogicoFin(listaDetailMarLogFM);

        return mapping.findForward("progEstraInvMetaFin");
    }

    public ActionForward loadPropositoMeta(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {


        ProgEstrForm form1 = (ProgEstrForm) form;
        int cod = Integer.parseInt(request.getParameter("cod"));// codigo de fin, proposito, componente
        String desc = request.getParameter("desc");// descripcion de fin, proposito, componente
        String descPrograma = request.getParameter("descPrograma");// descripcion de programa
        int codPrograma = Integer.parseInt(request.getParameter("codPrograma"));
        form1.setPk(codPrograma);
        form1.setTitu_programa(descPrograma);
        form1.setMetaFin(desc);
        form1.setCodPrograma(cod);

        List listaDetailMarLogPM = new ProgEstrMarLogDaoPropositoMeta().getlistMarLogPropositoMeta(cod);

        form1.setListDetalleMarcoLogicoFin(listaDetailMarLogPM);

        return mapping.findForward("progEstraMarLogPropositoMeta");
    }

    public ActionForward loadPropositoMetaInv(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {


        ProgEstrForm form1 = (ProgEstrForm) form;
        int cod = Integer.parseInt(request.getParameter("cod"));// codigo de fin, proposito, componente
        String desc = request.getParameter("desc");// descripcion de fin, proposito, componente
        String descPrograma = request.getParameter("descPrograma");// descripcion de programa
 int codProposito= Integer.parseInt(request.getParameter("codPrograma"));
         form1.setPk(codProposito);
        form1.setTitu_programa(descPrograma);
        form1.setMetaFin(desc);
        form1.setCodPrograma(cod);

        List listaDetailMarLogPM = new ProgEstrMarLogDaoPropositoMeta().getlistMarLogPropositoMetaInv(cod);

        form1.setListDetalleMarcoLogicoFin(listaDetailMarLogPM);

        return mapping.findForward("progEstraInvPropositoMeta");
    }

    public ActionForward loadComponenteMeta(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {


        ProgEstrForm form1 = (ProgEstrForm) form;
        int cod = Integer.parseInt(request.getParameter("cod"));// codigo de fin, proposito, componente
        String desc = request.getParameter("desc");// descripcion de fin, proposito, componente
        String descPrograma = request.getParameter("descPrograma");// descripcion de programa
        int codPrograma = Integer.parseInt(request.getParameter("codPrograma"));
        form1.setPk(codPrograma);
        form1.setTitu_programa(descPrograma);
        form1.setMetaFin(desc);
        form1.setCodPrograma(cod);

        List listaDetailMarLogPM = new ProgEstrMarLogDaoComponenteMeta().getlistMarLogComponenteMeta(cod);

        form1.setListDetalleMarcoLogicoFin(listaDetailMarLogPM);

        return mapping.findForward("progEstraMarLogComponenteMeta");
    }

    public ActionForward loadComponenteMetaI(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {


        ProgEstrForm form1 = (ProgEstrForm) form;
        int cod = Integer.parseInt(request.getParameter("cod"));// codigo de fin, proposito, componente
        String desc = request.getParameter("desc");// descripcion de fin, proposito, componente
        String descPrograma = request.getParameter("descPrograma");// descripcion de programa
         int codComponente= Integer.parseInt(request.getParameter("codPrograma"));
         form1.setPk(codComponente);
        form1.setTitu_programa(descPrograma);
        form1.setMetaFin(desc);
        form1.setCodPrograma(cod);

        List listaDetailMarLogPM = new ProgEstrMarLogDaoComponenteMeta().getlistMarLogComponenteMetaI(cod);

        form1.setListDetalleMarcoLogicoFin(listaDetailMarLogPM);

        return mapping.findForward("progInvComponenteMeta");
    }



    public ActionForward loadComponenteRubroI(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {


        ProgEstrForm form1 = (ProgEstrForm) form;
        int cod = Integer.parseInt(request.getParameter("cod"));// codigo de fin, proposito, componente
        String desc = request.getParameter("desc");// descripcion de fin, proposito, componente
        String descPrograma = request.getParameter("descPrograma");// descripcion de programa
        //int codComponente= Integer.parseInt(request.getParameter("codPrograma"));
        //form1.setPk(codComponente);
        form1.setTitu_programa(descPrograma);
        form1.setMetaFin(desc);
        form1.setCodPrograma(cod);

        //List listaDetailMarLogPM = new ProgEstrMarLogDaoComponenteMeta().getlistMarLogComponenteMetaI(cod);

        //form1.setListDetalleMarcoLogicoFin(listaDetailMarLogPM);

        return mapping.findForward("progInvComponenteRubro");
    }

    public ActionForward listarProyectosdeInversion(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        ProgEstrForm form1 = (ProgEstrForm) form;
        //UsuarioRolForm form1 = (UsuarioRolForm) form;
        List listOGE = new ProgEstrDao().getlistOGE();
        List listOEE = new ProgEstrDao().getlistOEE(0);
        List listActividades = new ProgEstrDao().getlistActividades(0);


        List listAnios = new ProgEstrDao().getlistAnios();
        List listTableTituProg = new ProyectoInversionDao().getListTituProgForTable();
        List region = new ProgEstrDao().getRegion();
//         form1.setListaRol(null);
        form1.setOGE(listOGE);
//        JOptionPane.showMessageDialog(null, form1.getOGE().size());
        form1.setOEE(listOEE);
        form1.setACTIVIDAD(listActividades);
        form1.setListAnio(listAnios);
        form1.setListTableTituProg(listTableTituProg);
        form1.setListRegion(region);


        return mapping.findForward("proyectosInversion");
    }

    public ActionForward grabarProyectoInversion(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        ProgEstrForm form1 = (ProgEstrForm) form;
        int cod = Integer.parseInt(request.getParameter("cod"));

        int codAct = Integer.parseInt(request.getParameter("codActPer"));
        int tipo = Integer.parseInt(request.getParameter("tipo"));



        String codDistrito = request.getParameter("codDistrito");
        String proyecto = form1.getTitu_programa();
        String desProyecto = form1.getJustificacion();
        String fechaInicio = form1.getFechaInicio();
        String fechaFin = form1.getFechaFin();
        int numConvenio = form1.getNumConvenio();
        int anio = form1.getCodAnio();
        BigDecimal monto = form1.getMonto();
        String adjunto = form1.getAdjunto();
        int criterio = Integer.parseInt(request.getParameter("numCriterio"));

        
        //JOptionPane.showMessageDialog(null, criterio);
        int slegal = Integer.parseInt(request.getParameter("saneamientoLegal"));
        int slegal2 = Integer.parseInt(request.getParameter("saneamientoLegal2"));
        int slegal3 = Integer.parseInt(request.getParameter("saneamientoLegal3"));
        int nroRegistro = form1.getNmroRegistro();



        ProyectosInversionVO piVO = new ProyectosInversionVO(codDistrito, codAct, nroRegistro, slegal,slegal2,slegal3, criterio, numConvenio, fechaFin, fechaInicio, proyecto, desProyecto, cod, adjunto, adjunto, anio, monto);
        new ProyectoInversionDao().spMan(tipo, piVO);


        return listarProyectosdeInversion(mapping, form, request, response);

    }

    public ActionForward ingresarPInversion(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        ProgEstrForm form1 = (ProgEstrForm) form;
        //UsuarioRolForm form1 = (UsuarioRolForm) form;
        List listOGE = new ProgEstrDao().getlistOGE();
        List listOEE = new ProgEstrDao().getlistOEE(0);
        List listActividades = new ProgEstrDao().getlistActividades(0);
        //String flagOper=request.getParameter("flagOper");

        //form1.setMetaFin(flagOper);

        List listAnios = new ProgEstrDao().getlistAnios();
        List listTableTituProg = new ProyectoInversionDao().getListTituProgForTable();
        List region = new ProgEstrDao().getRegion();
//         form1.setListaRol(null);
        form1.setOGE(listOGE);
//        JOptionPane.showMessageDialog(null, form1.getOGE().size());
        form1.setOEE(listOEE);
        form1.setACTIVIDAD(listActividades);
        form1.setListAnio(listAnios);
        form1.setListTableTituProg(listTableTituProg);
        form1.setListRegion(region);


        return mapping.findForward("ingresarPInversion");
    }

    public ActionForward rubro(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        //ProgEstrForm form1 = (ProgEstrForm) form;
        //UsuarioRolForm form1 = (UsuarioRolForm) form;
        //List listOGE = new ProgEstrDao().getlistOGE();
        //List listOEE = new ProgEstrDao().getlistOEE(0);
        //List listActividades = new ProgEstrDao().getlistActividades(0);
        //String flagOper=request.getParameter("flagOper");

        //form1.setMetaFin(flagOper);

        //List listAnios = new ProgEstrDao().getlistAnios();
        //List listTableTituProg=new ProyectoInversionDao().getListTituProgForTable();
        // List region=new ProgEstrDao().getRegion();
//         form1.setListaRol(null);
        //form1.setOGE(listOGE);
//        JOptionPane.showMessageDialog(null, form1.getOGE().size());
        //form1.setOEE(listOEE);
        // form1.setACTIVIDAD(listActividades);
        //form1.setListAnio(listAnios);
        //form1.setListTableTituProg(listTableTituProg);
        //form1.setListRegion(region);


        return mapping.findForward("rubro");
    }

    public ActionForward editarPInversion(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        ProgEstrForm form1 = (ProgEstrForm) form;

        //UsuarioRolForm form1 = (UsuarioRolForm) form;
        List listOGE = new ProgEstrDao().getlistOGE();
        List listOEE = new ProgEstrDao().getlistOEE(0);
        List listActividades = new ProgEstrDao().getlistActividades(0);
        int idPInvercion = Integer.parseInt(request.getParameter("pk"));
        int flag = 2;
        form1.setFlag(flag);
        String oee = request.getParameter("oee");
        String oge = request.getParameter("oge");
        String aper = request.getParameter("ap");
        String dep = request.getParameter("dep");
        String prov = request.getParameter("prov");
        String dist = request.getParameter("dist");


        List listAnios = new ProgEstrDao().getlistAnios();
        ProyectosInversionVO vo = new ProyectoInversionDao().getListTituProgForId(idPInvercion);
        List region = new ProgEstrDao().getRegion();
//         form1.setListaRol(null);
        form1.setOee(oee);
        //    form1.setOge(oge);
        //   form1.setAp(aper);
        form1.setDescRegion(dep);
        form1.setDescProvincia(prov);
        form1.setDescDistrito(dist);
        form1.setAp(aper);

        form1.setOGE(listOGE);
        form1.setPk(idPInvercion);
        form1.setOEE(listOEE);
        form1.setACTIVIDAD(listActividades);
        form1.setListAnio(listAnios);

        //form1.setMetaFin(flagOper);


        form1.setListRegion(region);

        form1.setPk(vo.getNUM_PYINV_PK());


        form1.setTitu_programa(vo.getTX_NOMBREPYI());
        form1.setJustificacion(vo.getTX_DESCACTPER());
        form1.setFechaInicio(vo.getDT_INIPYI());
        form1.setFechaFin(vo.getDT_TERPYI());
        form1.setNumConvenio(vo.getNUM_SNIPPYI());
        form1.setCodAnio(vo.getNUM_ANIOPRESUPYI_PK());
        form1.setMonto(vo.getNUM_PRESUPYI());
        form1.setAdjunto(vo.getTX_ADJUARBP());

        form1.setNumCriterio(vo.getNUM_CRITERIOPYI());
        form1.setTipocriterio(vo.getNUM_CRITERIOPYI());
        form1.setSaneamientoLegal(vo.getNUM_SANEAPYI());
        form1.setSaneamientoLegal2(vo.getNUM_SANEAPYI2());
        form1.setSaneamientoLegal3(vo.getNUM_SANEAPYI3());


        form1.setTiposaneamiento(vo.getNUM_SANEAPYI());
        //JOptionPane.showMessageDialog(null, vo.getNUM_SANEAPYI());
        form1.setNmroRegistro(vo.getNUM_NROREGPYI());
        form1.setJustificacion(vo.getTX_DESCPYI());
        //      form1.setCodOge(Integer.parseInt(vo.getNUM_CODOBJ_PK()));
        //       form1.setTipoobj(Integer.parseInt(vo.getNUM_CODOBJ_PK()));
        //       form1.setCodOee(Integer.parseInt(vo.getNUM_CODOBJESP_PK()));
        //       form1.setTipoobje(Integer.parseInt(vo.getNUM_CODOBJESP_PK()));
        //     form1.setCodActPer(vo.getNUM_CODACTPER_PK());
        //    form1.setTipoactp(vo.getNUM_CODACTPER_PK());
        //      form1.setRegion(vo.getNUM_CODDPTO_PK());
        //      form1.setTiporegion(vo.getNUM_CODDPTO_PK());
        //     form1.setProvincia(vo.getNUM_CODPRV_PK());
        form1.setTipoprovincia(vo.getNUM_CODPRV_PK());
        form1.setDistrito(vo.getNUM_CODDIST_PK());
        form1.setTipodistrito(vo.getNUM_CODDIST_PK());


        //Ini agregado
        //"codObj,codObjEsp,codActPer,codDpto,codPrv,codDist;
        String codObj=StringUtils.isEmpty(request.getParameter("codObj")) ? "-1"
                            : request.getParameter("codObj");
        String codObjEsp=StringUtils.isEmpty(request.getParameter("codObjEsp")) ? "-1"
                            : request.getParameter("codObjEsp");
        String codActPer=StringUtils.isEmpty(request.getParameter("codActPer")) ? "-1"
                            : request.getParameter("codActPer");
        String codDpto=StringUtils.isEmpty(request.getParameter("codDpto")) ? "-1"
                            : request.getParameter("codDpto");
        String codPrv=StringUtils.isEmpty(request.getParameter("codPrv")) ? "-1"
                            : request.getParameter("codPrv");
        String codDist=StringUtils.isEmpty(request.getParameter("codDist")) ? "-1"
                            : request.getParameter("codDist");
        String adjunto=StringUtils.isEmpty(request.getParameter("adjunto")) ? ""
                            : request.getParameter("adjunto");

        
        List OEE=new ProgEstrDao().getlistOEE(Integer.parseInt(codObj));
        List ACTIVIDAD=new ProgEstrDao().getlistActividades(Integer.parseInt(codObjEsp));
        List listProvincia=new ProgEstrDao().getComboProvincia(codDpto);
        List listDistrito=new ProgEstrDao().getComboDistrito(codPrv);

        form1.setACTIVIDAD(ACTIVIDAD);
        form1.setOEE(OEE);
        form1.setListProvincia(listProvincia);
        form1.setListDistrito(listDistrito);

        form1.setCodOge(Integer.parseInt(codObj));
        form1.setCodOee(Integer.parseInt(codObjEsp));
        form1.setRegion(codDpto);
        form1.setProvincia(codPrv);
        form1.setDistrito(codDist);
        form1.setAdjunto(adjunto);


        //Fin agregado

        return mapping.findForward("editarPInversion");
    }

    public ActionForward proyectos(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        ProgEstrForm form1 = (ProgEstrForm) form;
        List listaFinMarcoLogico = new MarcoLogicoDao().getlistMarcoLogicoFin();
        List listaPropMarcoLogico = new MarcoLogicoDao().getlistMarcoLogicoProposito();
        List listaCompMarcoLogico = new MarcoLogicoDao().getlistMarcoLogicoComponente();
        List listaDetailMarLogFin = new MarcoLogicoDao().getlistMarcoLogicoProgramaI();

        //List listaDetailMarLogFin =new ProgEstrMarLogDao().getlistFinInv(codPrograma);
        //form1.setListDetalleMarcoLogicoProposito(listaPropMarcoLogico);
        //form1.setListDetalleMarcoLogicoFin(listaFinMarcoLogico);
        //form1.setListDetalleMarcoLogicoComponente(listaCompMarcoLogico);


        form1.setListPrograma(listaDetailMarLogFin);
        form1.setListDetalleMarcoLogicoProposito(listaPropMarcoLogico);
        form1.setListDetalleMarcoLogicoFin(listaFinMarcoLogico);
        form1.setListDetalleMarcoLogicoComponente(listaCompMarcoLogico);


        return mapping.findForward("proyectos");
    }

    public ActionForward poi(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        ProgEstrForm form1 = (ProgEstrForm) form;

     
        //UsuarioRolForm form1 = (UsuarioRolForm) form;
        List listOGE = new ProgEstrDao().getlistOGE();
        List listOEE = new ProgEstrDao().getlistOEE(0);
        List listActividades = new ProgEstrDao().getlistActividades(0);
        //String flagOper=request.getParameter("flagOper");

        //form1.setMetaFin(flagOper);

        List listAnios = new ProgEstrDao().getlistAnios();
     //   List anioss= new ProgEstrDao().getlistAnios();
        
        String id= request.getParameter("id");
        String anio= request.getParameter("anio");
        if(id==null && anio==null){
            
        }else{
        List listTableTituProg = new ProyectoInversionDao().getReportePOI(Integer.parseInt(id),Integer.parseInt(anio));
        form1.setListTableTituProg(listTableTituProg);
        }

        
        List region = new ProgEstrDao().getRegion();
//         form1.setListaRol(null);
        form1.setOGE(listOGE);
//        JOptionPane.showMessageDialog(null, form1.getOGE().size());
        form1.setOEE(listOEE);
        form1.setACTIVIDAD(listActividades);
        form1.setListAnio(listAnios);
   //     form1.setLista(anioss);
    //    request.getSession().setAttribute("listAnio",  anioss );  sessionScope.test3
       
        form1.setListRegion(region);

        return mapping.findForward("poi");
    }
}
